def is_rect(pos, rect):
    """
    判断点的范围
    """
    x, y = pos
    rx, ry, rw, rh = rect
    if (rx <= x <= rw) and (ry <= y <= rh):
        return True
    return False

def vector(p0, p1):
    """返回点的速度
    p0 = (xo,yo), p1 = (x1,y1)"""
    a = p1[0] - p0[0]
    b = p1[1] - p0[1]
    return (a, b)


def unit_vector(v):
    """返回点的单位向量
    v = (a,b)"""
    h = ((v[0]**2)+(v[1]**2))**0.5
    if h == 0:
        h = 0.000000000000001
    ua = v[0] / h
    ub = v[1] / h
    return (ua, ub)


def distance(xo, yo, x, y):
    """两点的距离"""
    dx = x - xo
    dy = y - yo
    d = ((dx ** 2) + (dy ** 2)) ** 0.5
    return d